home *** CD-ROM | disk | FTP | other *** search
- Path: news1.cle.ab.com!usenet
- From: don.phillips@ab.com (Donald-Anthony C. Phillips)
- Newsgroups: comp.lang.c
- Subject: Re: Finding a prime number
- Date: Fri, 26 Jan 1996 22:05:27 GMT
- Organization: The Allen-Bradley Co., Inc
- Distribution: inet
- Message-ID: <4eb8lo$9rf@news1.cle.ab.com>
- References: <4e875s$nqk@reader2.ix.netcom.com>
- NNTP-Posting-Host: abpc386.cle.ab.com
- X-Newsreader: Forte Free Agent 1.0.82
-
- It seems your algorithm may not be mathematically correct. Your
- assumption( if i'm reading your code right) is that if a number is not
- divisible evenly by any of the numbers 0-9, then it must be prime.
- This is not correct.
- Take for instance the number 247. It is not divisible by 0-9 but it
- is not a prime number( 13*19 = 247). The definition of a prime number
- is a number divisible only by one and the number.
- Most prime number algorithms will be iterative or recursive by nature.
- A number (n) is prime if is not divisible by any number from 2 thru
- (n - 1) .....roughly. There are also some much more theoretical
- models that can be used but the previous definition will do.
- Donald-Anthony C. Phillips
- Programmer/Analyst
- Rockwell Automation
- ---------------------------------------
- Allen-Bradley
- don.phillips@ab.com
-
-